package com.itboye.jinpuyiyuan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.jinpuyiyuan.R;
import com.itboye.jinpuyiyuan.bean.BranchBean;
import com.itboye.jinpuyiyuan.bean.LaborInfoBean;

import java.util.ArrayList;
import java.util.List;

public class LaborDetailAdapter extends BaseAdapter {

    private List<LaborInfoBean.Check.Detail> list;
    private Context context;
    private LayoutInflater inflater;
    public  LaborDetailAdapter(Context context,List<LaborInfoBean.Check.Detail> list){

        this.list=list;
        this.context=context;
        inflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LaborDetailAdapter.MyViewHolder myViewHolder;
        if (convertView==null){
            myViewHolder=new LaborDetailAdapter.MyViewHolder();
            convertView=inflater.inflate(R.layout.item_labordetail,parent,false);
            myViewHolder.first=convertView.findViewById(R.id.first);
            myViewHolder.two=convertView.findViewById(R.id.two);
            myViewHolder.three=convertView.findViewById(R.id.three);
            myViewHolder.four=convertView.findViewById(R.id.four);
            myViewHolder.five=convertView.findViewById(R.id.five);
            convertView.setTag(myViewHolder);
        }else {
            myViewHolder= (MyViewHolder) convertView.getTag();
        }
        myViewHolder.first.setText(list.get(position).getCheck_name());
        myViewHolder.two.setText(list.get(position).getResult());
        myViewHolder.three.setText(list.get(position).getUnit());
        myViewHolder.four.setText(list.get(position).getNormal_flag());
        myViewHolder.five.setText(list.get(position).getReference_value());
        return convertView;
    }

    public void addData(List<LaborInfoBean.Check.Detail> list){
        this.list=list;
        this.notifyDataSetChanged();
    }
    class MyViewHolder{
        private TextView first,two,three,four,five;
    }
}
